package com.recipedb.recipedb.entity;

import jakarta.persistence.*;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Entity
@IdClass(LikesId.class) // 指定复合主键类
@Table(name = "likes")
public class Likes {

    // getters & setters
    @Id
    @Column(name = "user_id")
    private Long userId;

    @Id
    @Column(name = "recipe_id")
    private Long recipeId;

    @Column(name = "created_at")
    private LocalDateTime createdAt = LocalDateTime.now();

    public Likes() {}

    public Likes(Long userId, Long recipeId) {
        this.userId = userId;
        this.recipeId = recipeId;
    }

    public void setUserId(Long userId) { this.userId = userId; }

    public void setRecipeId(Long recipeId) { this.recipeId = recipeId; }

    public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
}